Compile 2015 VS Community Workflow

UNDER CONSTRUCTION

Aim

To show one workflow for setting up a Windows pc for compiling OpenCPN.

The pc used was a 'win-32-x86 machine', running Windows 8.1.

If you are running 'x64' you will need to download the 64 bit installers for some of the programs used here. This applies to:

The steps will follow the instructions here.

'Navigate' means using 'Windows Explorer' to find a folder or file.

'cd' or 'CD' is used in a Terminal window to 'change directory' (aka 'change folder')

Method

Install Visual Studio Community 2015

https://www.visualstudio.com/downloads


Note:


Install Git

Get the Git installation packages from https://git-for-windows.github.io/

Install CMake

Install Poedit

Get the latest 'Poedit' installation package from http://www.poedit.net

  1. Install 'Poedit'.
  2. Add 'C:\Program Files\Poedit\GettextTools\bin' to the PATH environment variable.

Note: If you look in the 'C:\Program Files\Poedit\GettextTools\bin' folder you will see the file 'msgfmt.exe' which does the work of the program.

Install NSIS

In case you want to create installation packages, install NSIS Unicode 2.46.5 from http://www.scratchpaper.com/

There is a “bug” in CMake, which only looks at “HKEY_LOCAL_MACHINE\SOFTWARE\NSIS” for the installation location of NSIS

The Unicode version adds its registry key in “HKEY_LOCAL_MACHINE\SOFTWARE\NSIS\Unicode”.

Some registry tweaking is needed.

Note: If you are running a 64-bit machine (x64) the key is located in 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\NSIS\Unicode'

Note: If you are running a 64-bit machine (x64) the location is 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\NSIS'.

To make the installer package use proper language name translations, it is necessary to modify file 'C:\Program Files\NSIS\Unicode\Contrib\Language files\Norwegian.nsh' and change the line

!insertmacro LANGFILE "Norwegian" "Norwegian"

to

!insertmacro LANGFILE "Norwegian" "Norsk"

The 'C:\Program Files\NSIS\Unicode\Contrib\Language files\Norwegian.nsh' is edited.

Due to 'Security' you will need to add 'Write' permission to this file. Without this you will not be able to save the changes.

Compile wxWidgets 3.0.2

Compile wxWidgets with Visual Studio Community 2015

1) <wxdir>\src\zlib\gzguts.h - line 102
change:

Code: Select all
#ifdef _MSC_VER
#  define snprintf _snprintf
#endif

to:

Code: Select all
#if (defined(_MSC_VER) && (_MSC_VER <1900))
  #define snprintf _snprintf
#endif

2) <wxdir>\src\tiff\libtiff\tif_config.h - line 367
change:

Code: Select all
#define snprintf _snprintf

to:

Code: Select all
#if (defined(_MSC_VER) && (_MSC_VER <1900))
  #define snprintf _snprintf
#endif

3) <wxdir>\include\wx\propgrid\advprops.h - line 453
change:

Code: Select all
wxDateTime GetDateValue() const
{
    //return m_valueDateTime;
    return m_value;
}

to:

Code: Select all
wxDateTime GetDateValue() const
{
    //return m_valueDateTime;
    return m_value.GetDateTime();
}

Line numbers based on wxWidgets 3.0.2 (not the latest development version).

You will find that a number of files have been made in the folder 'c:\wxWidgets-3.0.2\lib\vc-dll'.

Some of the filenames start 'wxmsw30u' and others 'wxmsw30ud' corresponding to the 'Release' and 'Debug' versions.

This completes the preparations for building the OpenCPN program.

Building OpenCPN

Get the OpenCPN source

git clone git://github.com/OpenCPN/OpenCPN.git


Note: If you want the source code for the latest stable release (4.4.0 at time of writing) you need to locate that source on GitHub.com:

https://github.com/OpenCPN/OpenCPN/tree/v4.4.0


Get the binary dependency files

Sorry, this needs another program - 7Zip.

'7z' files can now be opened and extracted with this program.

Make a Visual Studio solution for building OpenCPN

mkdir build
cd build
cmake -T v140_xp ..

* Close the Terminal window.
* This has created the Visual Studio solution file 'OpenCPN.sln'.

Build OpenCPN


wxmsw30u_richtext.lib
wxmsw30u_adv.lib
wxmsw30u_propgrid.lib
wxmsw30u_aui.lib




Make a package to install OpenCPN

This assumes that you have installed 'NSIS' (The guide was here).

Install OpenCPN

OpenCPN (Version 4.4.0) and the four plugins included in the source files have been built successfully.


In order to run the setup on Windows XP it is necessary to download and run the 'Microsoft Visual C++ Redistributable 2015' installer

This was downloaded from here. I had problems with the version I found elsewhere on Microsoft.